﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Shapes;
using Chemistry.Models;
using Chemistry.ViewModels;
using GalaSoft.MvvmLight.Messaging;
using MahApps.Metro.Controls;
using MahApps.Metro.Controls.Dialogs;

namespace Chemistry.Views
{
    /// <summary>
    /// ExamineeLogin.xaml 的交互逻辑
    /// </summary>
    public partial class ExamineeLogin : MetroWindow
    {

        private MetroDialogSettings _settings;
        ProgressDialogController controller;
        public ExamineeLogin()
        {
            InitializeComponent();
            Closing += ExamineeLogin_Closing;
            _settings = new MetroDialogSettings()
            {
                AffirmativeButtonText = "确定",
                NegativeButtonText = "取消",

            };

            Messenger.Default.Register<ExamInfo>(this, MessageToken.ShowGuideWindow, (i) =>
            {
                GuideWindow win = new GuideWindow();
                win.ExamineeLoginWindow = this;
                win.Show();
                this.Hide();
            });

            //Messenger.Default.Register<string>(this, MessageToken.ShowExamMessage, async (i) =>
            //{
            //    await this.ShowMessageAsync("提示", i, MessageDialogStyle.Affirmative, _settings);
                 
            //});

            Messenger.Default.Register<string>(this, MessageToken.ShowExamLoadMessage, async (i) =>
            {

                //  MessageBox.Show(i, "提示");

                controller = await this.ShowProgressAsync("提示", i);
                //controller.SetIndeterminate();

                //controller = controller1;
            });

            Messenger.Default.Register<string>(this, MessageToken.CloseExamLoadMessage, async (i) =>
            {
                if (controller != null)
                {
                    await controller.CloseAsync();
                }

            });

            //Messenger.Default.Register<string>(this, MessageToken.ShowExamMessage, async (i) =>
            //{
            //    await this.ShowMessageAsync("提示", i, MessageDialogStyle.Affirmative, _settings);

            //});
        }

        void ExamineeLogin_Closing(object sender, System.ComponentModel.CancelEventArgs e)
        {
            Application.Current.Shutdown();
        }

        private void Button_Click(object sender, RoutedEventArgs e)
        {
            ConfigWindow win = new ConfigWindow();
            win.ShowDialog();
        }
    }
}
